package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ExamResult;
import com.ruoyi.system.service.IExamResultService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 检查结果Controller
 * 
 * @author ruoyi
 * @date 2024-07-02
 */
@RestController
@RequestMapping("/check/Check_Result")
public class ExamResultController extends BaseController
{
    @Autowired
    private IExamResultService examResultService;

    /**
     * 查询检查结果列表
     */
    @PreAuthorize("@ss.hasPermi('check:Check_Result:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExamResult examResult)
    {
        startPage();
        List<ExamResult> list = examResultService.selectExamResultList(examResult);
        return getDataTable(list);
    }

    /**
     * 导出检查结果列表
     */
    @PreAuthorize("@ss.hasPermi('check:Check_Result:export')")
    @Log(title = "检查结果", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExamResult examResult)
    {
        List<ExamResult> list = examResultService.selectExamResultList(examResult);
        ExcelUtil<ExamResult> util = new ExcelUtil<ExamResult>(ExamResult.class);
        util.exportExcel(response, list, "检查结果数据");
    }

    /**
     * 获取检查结果详细信息
     */
    @PreAuthorize("@ss.hasPermi('check:Check_Result:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(examResultService.selectExamResultById(id));
    }

    /**
     * 新增检查结果
     */
    @PreAuthorize("@ss.hasPermi('check:Check_Result:add')")
    @Log(title = "检查结果", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExamResult examResult)
    {
        return toAjax(examResultService.insertExamResult(examResult));
    }

    /**
     * 修改检查结果
     */
    @PreAuthorize("@ss.hasPermi('check:Check_Result:edit')")
    @Log(title = "检查结果", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExamResult examResult)
    {
        return toAjax(examResultService.updateExamResult(examResult));
    }

    /**
     * 删除检查结果
     */
    @PreAuthorize("@ss.hasPermi('check:Check_Result:remove')")
    @Log(title = "检查结果", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(examResultService.deleteExamResultByIds(ids));
    }
}
